﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShoppingCart.aspx.cs" Inherits="Sbook.ShoppingCart" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Src="~/Control/Menu/Header.ascx" TagName="Header" TagPrefix="UC" %>
<%@ Register Src="~/Control/Menu/MenuRight.ascx" TagName="MenuRight" TagPrefix="UC" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Giỏ hàng</title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.simplyscroll.js"></script>
    <%--<script src="Scripts/ChangePass.js" type="text/javascript"></script>--%>
    <!-- script menutop -->
    <script type="text/javascript">
        $(document).ready(function () {
            $(".menu_top li").hover(function () {
                $(this).find('ul:first').css({ visibility: "visible", display: "none" }).show(500)
            }, function () {
                $(this).find('ul:first').css({ visibility: "hidden" })
            });
        });
    </script>
    <link type="text/css" rel="stylesheet" href="css/jquery.simplyscroll_splienquan.css" />
    <link type="text/css" rel="stylesheet" href="css/style_chitietsp.css" />
</head>
<body>
    <center>
        <div class="web">
            <UC:Header runat="server" ID="header1" />
            <div class="chitietsp">
                <div class="chitietsp_top">
                    <a href="#">Cặp sách</a>
                </div>
                <div class="sanpham">
                    <form id="form1" runat="server"  style="margin-top:20px;">
                    <div>
                        <asp:DataGrid runat="server" ID="grdShoppingCart" Width="99%" AutoGenerateColumns="false" OnItemCommand="grdShoppingCart_ItemCommand">
                            <Columns>
                                <asp:BoundColumn DataField="PName" HeaderText="Tên sản phẩm" Visible="true"></asp:BoundColumn>
                                <%-- <asp:BoundColumn DataField="PImg" HeaderText="Hinh anh" Visible="true"></asp:BoundColumn>--%>
                                <asp:TemplateColumn>
                                    <HeaderTemplate>
                                        Hình ảnh</HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:Image runat="server" Width="80px" Height="80px" ID="imgProduct" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"PImg") %>' />
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                               <%-- <asp:BoundColumn DataField="Quantity" HeaderText="Số lượng" Visible="true"></asp:BoundColumn>--%>
                               <asp:TemplateColumn>
                                    <HeaderTemplate>Số lượng</HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:TextBox runat="server" ID="txtQuantity" Width="30px" Text='<%#DataBinder.Eval(Container.DataItem,"Quantity")%>'></asp:TextBox>
                                    </ItemTemplate>
                               </asp:TemplateColumn>
                                <asp:BoundColumn DataField="Price" HeaderText="Giá bán" Visible="true"></asp:BoundColumn>
                                <asp:BoundColumn DataField="DeliveryPrice" HeaderText="Đơn giá" Visible="true"></asp:BoundColumn>
                                
                                <asp:BoundColumn DataField="UId" HeaderText="Người mua" Visible="false"></asp:BoundColumn>
                                <asp:BoundColumn DataField="ProductId" HeaderText="ID" Visible="false"></asp:BoundColumn>
                                <asp:TemplateColumn>
                                    <HeaderTemplate>Chức năng</HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:LinkButton runat="server" ID="lbtEdit" OnClick="lbtEdit_Click" Text="Sửa" CommandName="Edit" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"ProductId") %>'></asp:LinkButton>
                                          <asp:LinkButton runat="server" ID="lbtDelete" OnClick="lbtDelete_Click" OnClientClick="javascript:return confirm('Bạn chắc muốn xóa ?');" Text="Xóa" CommandName="Delete" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"ProductId") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                            </Columns>
                        </asp:DataGrid>
                        
                        <div style="float:right; margin-right:20px;"><asp:Label runat="server" ID="lblTotal" Text=""></asp:Label></div>
                        <div style="float:right"><asp:Label runat="server" ID="lbl" Text="Tổng tiền :" ></asp:Label></div>
                        <div style="float:right; margin-right:150px; margin-top:50px;">
                            <a href="/index.aspx" style="color:red; font-size:16px; font-weight:bold;">Tiếp tục</a>
                            <a href="#" id="thanhtoan" style="color:red; font-size:16px; font-weight:bold;">Thanh toán</a>
                        </div>
                       <%-- <div id="select" style ="position:absolute; color:White; z-index:1000; display:none; width:186px; top:326px; left:250px; height:80px; background-color:Green">
                            <a style="color:White" href="ThanhToan.aspx?u=<%=Uid %>">Địa chỉ cũ</a>
                            <a style="color:White"  href="ThanhToan.aspx?">Địa chỉ mới</a>
                        </div>--%>
                       
                        <strong style="display:none;" id="Me"><%=Uid %></strong>
                        <strong style="display:none" id="total"><%=Total %></strong>
                    </div>
                    </form>
                </div>
            </div>
            <div class="right">
                <!-- danh mục phải -->
                <div class="menu_right">
                    <UC:MenuRight runat="server" ID="MenuRight"></UC:MenuRight>
                    <script type="text/javascript">
                        $(document).ready(function () {
                            $("div.right div.menu_right ul:not(first)").hide();
                            $('ul#f1').show();
                            $('h2.menu_head').click(function () {

                                $('.active').removeClass('active');
                                $(this).addClass('active');
                                $('ul').slideUp('slow');
                                $(this).next('ul').slideDown('slow');
                                var content_show = $(this).attr('title');
                                $('#' + content_show).slideDown('slow');

                            });
                            $('a#thanhtoan').click(function () {
                                var Total = $('strong#total').html();
                                if (Total == "0") {
                                    alert('chưa có hàng');
                                    return;
                                }
                                else {
                                    $(this).attr("href", "ThanhToanHot.aspx");
                                }
                            });
                        });
                    </script>
                </div>
                <!-- close danh mục phải -->
            </div>
        </div>

        <style>
    #divChangePass{ width:500px; height:235px; position:absolute; display:none; background-color:White; border:1px solid #CCFFFF; left:385px; top:160px; z-index:1000}
    #divChangePass ul { float:left; width:100%; list-style:none;}
    #divChangePass ul li{ float:left; width:100%; margin-top:10px;}
    #divChangePass ul li span{ color:Red; display:none}
    #divChangePass ul li label{ float:left; width:200px; text-align:right; padding-right:5px;}
    #divChangePass ul li input[type=password]{ float:left;}
    #divChangePass h1{ color:Red; font-size:25px}
    #divChangePass a{ float:right; margin:0px 0px; padding:0px 0px }
</style>
        <div id="divChangePass">
    <a href="#" id="closeChangePass">X</a>
    <form id="frm2">
        <h1>Đổi mật khẩu</h1>
        <ul>
            <li><label>Mật khẩu cũ:</label> <input type="password" id="txtOldPass" /><span id="spOldPass">Không được để trống.</span></li>
            <li><label>Mật khẩu mới:</label> <input type="password" id="txtNewPass" /><span id="spNewPass">Không được để trống.</span></li>
            <li><label>Xác nhận mật khẩu mới:</label> <input type="password" id="txtRePass" /><span id="spRePass">Không được để trống.</span></li>
            <li><input type="button" value="Đổi mật khẩu" id="btnChangePass" /></li>
        </ul>
    </form>

     <script type="text/javascript">
         $(document).ready(function () {
             var isLogin = $('#login').html();
             if (isLogin == "Đăng nhập") {
                 $('#logout').hide();
                 $('#Close').click(function () {
                     $('#divlogin').toggle(1000);
                 });
                 $('#login').click(function () {
                     $('#divlogin').toggle(1000);
                     $('#divDoiMK').css("display", "none");
                 });
             }
             else {
                 $('#logout').show();
                 //                        $('#login').attr("href", "http://hn.24h.com.vn");
                 $('#login').click(function () {

                     $('#divDoiMK').toggle(1000);
                 });
                 $('#CloseDMK').click(function () {
                     $('#divDoiMK').toggle(1000);
                 });
             }


             $('#dangnhap').click(function () {

                 var user = $('#user').val();
                 var pass = $('#pass').val();

                 window.location.href = "Demo.aspx?user=" + user + "&pass=" + pass;

             });
             //             Click đổi mật khẩu

             $('a#aDoiMK').click(function () {

                 $('div.web').css("opacity", "0.25");
                 $('div#divChangePass').css("display", "block");

                 $('#divDoiMK').toggle(1000);

             });
             $('a#closeChangePass').click(function () {
                 $('div.web').css("opacity", "1");
                 $('div#divChangePass').css("display", "none");

                 //                  $('#divDoiMK').toggle(1000);
             });

             $('div#divChangePass input[type=button]#btnChangePass').click(function () {

                 var OldPass = $('#txtOldPass').val();
                 var NewPass = $('#txtNewPass').val();
                 var RePass = $('#txtRePass').val();
                 var chkRePass = true;
                 if (OldPass == "") {
                     $('span#spOldPass').css("display", "block");
                 }
                 if (NewPass == "") {
                     $('span#spNewPass').css("display", "block");
                 }
                 if (RePass == "") {
                     $('span#spRePass').css("display", "block");
                 }


                 var chkOldPass;
                 if (OldPass != "" && NewPass != "" && RePass != "") {
                     $('div#divChangePass span').css("display", "none");

                     if (RePass != NewPass) {
                         $('span#spRePass').html("Xác nhận lại mật khẩu mới");
                         $('span#spRePass').css("display", "block");
                         chkRePass = false;
                     }
                     //check Exist OldPass
                     if (chkRePass == true) {
                         $.ajax({
                             type: "POST",
                             url: "/Page/DoiMatKhau.aspx",
                             data: { OldPass: OldPass, NewPass: NewPass },
                             success: function (data) {
                                 if (data == "0") {
                                     alert("Mật khẩu không đúng");
                                     chkOldPass = false;

                                 }
                                 else {

                                     chkOldPass = true;
                                     alert("Đổi mât khẩu thành công");
                                     window.location.href = "index.aspx";
                                 }

                             }
                         });

                     }
                     else {
                         return;
                     }

                 }
             });

         });
            </script>
</div>
    </center>
</body>
</html>
